package com.world.business.texture.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.world.common.enumeration.DelFlagEnum;
import com.world.common.security.SecurityUtils;
import com.world.business.texture.domain.Texture;
import com.world.business.texture.domain.query.TextureAddRequest;
import com.world.business.texture.mapper.TextureMapper;
import com.world.business.texture.service.ITextureService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 * 材质 服务实现类
 * </p>
 *
 * @author 邓驴
 * @since 2023-07-27
 */
@Service
public class TextureServiceImpl extends ServiceImpl<TextureMapper, Texture> implements ITextureService {

    @Override
    public Long add(TextureAddRequest request) {
        Texture build = Texture.builder()
                .name(request.getName())
                .rare(request.getRare())
                .forge(request.getForge())
                .status(request.getStatus())
                .remark(request.getRemark())
                .status("0")
                .createTime(LocalDateTime.now())
                .createById(SecurityUtils.getLoginUser().getId())
                .createBy(SecurityUtils.getLoginUser().getName())
                .delFlag(DelFlagEnum.NORMAL.getCode())
                .build();
        this.save(build);
        return build.getId();
    }
}
